<?php $this->load->view('home/layout/header') ?>
<?php js('skins/home', 'pages/address', 2)?>
<form action="<?php echo site_url('home/address/editPost'); ?>" method="post" id="address-form">
    <header class="my-head flex">
        <div class="city-return my-return">
            <a href="<?php echo site_url('home/address/addressList'); ?>">
                取消
            </a>
        </div>
        <div class="city-name my-name">
            编辑收货地址
        </div>
        <div class="add-submit">
            <button type="submit">保存</button>
        </div>
    </header>
    <section class="add-text widthMax" >
        <input type="hidden" name="address_id" value="<?php echo $addressInfo->address_id; ?>" >
        <input type="hidden" name="province_id" value="<?php echo $addressInfo->province_id; ?>" >
        <input type="hidden" name="city_id" value="<?php echo $addressInfo->city_id; ?>" >
        <input type="hidden" name="district_id" value="<?php echo $addressInfo->district_id; ?>" >
        <ul>
            <li>
                <h6>收件人姓名</h6>
                <div class="add-input flex-1">
                    <input type="text" name="receiver_name" value="<?php echo $addressInfo->receiver_name; ?>" placeholder="请填写收货人姓名" >
                </div>
            </li>
            <li>
                <h6>手机号码</h6>
                <div class="add-input flex-1">
                    <input type="tel" name="tel" maxlength="11" placeholder="11位手机号码" value="<?php echo $addressInfo->tel; ?>" >
                </div>
            </li>
            <li>
                <h6>邮政编码</h6>
                <div class="add-input flex-1">
                    <input type="tel" name="code" maxlength="6" placeholder="邮政编码" value="<?php echo $addressInfo->code; ?>" >
                </div>
            </li>
            <li>
                <h6>省、市、区</h6>
                <div class="add-input flex-1" data-am-modal="{target: '#region-alert'}">
                    <p id="region-name"><?php echo $addressInfo->province_name, $addressInfo->city_name, $addressInfo->district_name;; ?></p>
                </div>
            </li>
            <li>
                <h6>详细地址</h6>
                <div class="add-input flex-1">
                    <textarea wrap="hard" maxlength="50" name="detailed" placeholder="请填写详细地址"><?php echo $addressInfo->detailed; ?></textarea>
                </div> 
            </li>
        </ul>
    </section>
    <a href="javascript:;" class="addess-rem widthMax" id="delete-address" data-id="<?php echo $addressInfo->address_id; ?>">
            删除常用地址
    </a>
    <?php if ($addressInfo->is_default != 2) : ?>
        <footer class="addess-foot" data-am-sticky>
            <a href="<?php echo site_url('home/address/setDefaultAddress/'.$addressInfo->address_id); ?>">
                设置默认地址
            </a>
        </footer>
    <?php endif; ?>
    <div class="stadd-city am-modal-actions" id="region-alert">
        <div class="bank-head flex">
            <i class="iconfont  icon-cha" data-am-modal-close></i>
            <p class="flex-1">请选择城市</p>
        </div>
        <dl class="flex city-dl">
            <dd class="region-title"  data-type="1">
                <p id="province_name"><?php echo $addressInfo->province_name; ?></p>
            </dd>
            <dd class="region-title" id="cities-title" data-type="2">
                <p id="city_name"><?php echo $addressInfo->city_name; ?></p>
            </dd>
            <dd class="active region-title" id="districts-title" data-type="3">
                <p id="district_name"><?php echo $addressInfo->district_name; ?></p>
            </dd>
        </dl>
        <div class="city-blank flex">
            <div class="city-scroller scroller-provinces flex-1 ">
                <div class="scroller" id="provinces-list">
                    <?php if ($provinces->num_rows() > 0) : ?>
                    <ul>
                        <?php foreach( $provinces->result() as $value ) : ?>
                            <li data-id="<?php echo $value->region_id; ?>" data-type="<?php echo $value->region_type; ?>" <?php echo ($value->region_id == $addressInfo->province_id) ? 'class="active"' : ''; ?> >
                                <?php echo $value->region_name; ?>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                    <?php endif; ?>
                </div>
            </div>
            <div class="city-scroller scroller-cities flex-1 ">
                <div class="scroller" id="cities-list">
                    <?php if ( $cities->num_rows() > 0 ) : ?>
                    <ul>
                        <?php foreach( $cities->result() as $value ) : ?>
                        <li data-id="<?php echo $value->region_id; ?>" data-type="<?php echo $value->region_type; ?>" <?php echo ($value->region_id == $addressInfo->city_id) ? 'class="active"' : ''; ?> >
                            <?php echo $value->region_name; ?>
                        </li>
                        <?php endforeach; ?>
                    </ul>
                    <?php endif; ?>
                </div>
            </div>
            <div class="city-scroller scroller-districts flex-1 active">
                <div class="scroller" id="districts-list">
                    <?php if ($districts->num_rows() > 0) : ?>
                    <ul>
                        <?php foreach( $districts->result() as $value ) : ?>
                            <li data-id="<?php echo $value->region_id; ?>" data-type="<?php echo $value->region_type; ?>" <?php echo ($value->region_id == $addressInfo->district_id) ? 'class="active"' : ''; ?> >
                                <?php echo $value->region_name; ?>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</form>
<div class="am-modal alert-explain" tabindex="-1" id="my-confirm">
    <div class="am-modal-dialog">
        <div class="am-modal-bd">
            确定删除收货地址？
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
        </div>
    </div>
</div>
<?php $this->load->view('home/layout/footer'); ?>
